import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:lib_util/lib_util.dart';
import '../../../module_common/provider/wallet_info_provider.dart';
import '../../../module_common/widgets/image/public_image.dart';
import '../../../module_common/widgets/public_tip/public_tip.dart';

// 快，慢，繁忙
enum NewWorkStatus { green, red, warn }

class AssetsNetworkComp extends StatefulWidget {
  // final NodeList node;
  // required this.node
  AssetsNetworkComp({
    super.key,
  });

  @override
  State<StatefulWidget> createState() {
    return _AssetsNetworkCompState();
  }
}

class _AssetsNetworkCompState extends State<AssetsNetworkComp> {
  Color networkColor = Color.fromRGBO(58, 177, 151, 1);

  @override
  void initState() {
    super.initState();
  }

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return GestureDetector(
      onTap: () {
        bool isCopySuccess = Utils.copyText(context.read<WalletInfoNotifier>().walletAddress);
        Toast.show(context,
            position: Dpositon.bottom,
            message: isCopySuccess ? 'Copied successfully' : 'Copy failed',
            status: isCopySuccess ? '1' : '2');
      },
      child: Container(
        // height: double.infinity,
        padding: EdgeInsets.only(left: 20.w, top: 15.w),
        alignment: Alignment.bottomLeft,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            ConstrainedBox(
              constraints:  BoxConstraints(maxWidth: 140.w, maxHeight: 16.w),
              child: Text(
                '${context.watch<WalletInfoNotifier>().walletName}',
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
                style: TextStyle(
                    color: Color.fromRGBO(51, 51, 51, 1),
                    height: 16.w / 14.w,
                    fontWeight: FontWeight.w500,
                    fontSize: 14.sp),
              ),
            ),
            GestureDetector(
              onTap: () {
                bool isCopySuccess = Utils.copyText(context.read<WalletInfoNotifier>().walletAddress);
                Toast.show(context,
                    position: Dpositon.bottom,
                    message: isCopySuccess ? 'Copied successfully' : 'Copy failed',
                    status: isCopySuccess ? '1' : '2');
              },
              child: Container(
                height: 16.w,
                child: Row(
                  children: [
                    Text(
                      context.watch<WalletInfoNotifier>().walletFormatAddress,
                      style: TextStyle(
                        fontSize: 12.sp,
                        height: 17.w / 12.w,
                        fontWeight: FontWeight.w400,
                        color: Color.fromRGBO(134, 131, 145, 1),
                      ),
                    ),
                     SizedBox(
                      width: 5.w,
                    ),
                    PublicImage(
                      image: 'assets/images/wallet_assets/copy.png',
                      width: 15.w,
                      height: 15.w,
                    )
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
